#ifndef __CE_LOCK_H__
#define __CE_LOCK_H__

#include "ce_core.h"

typedef struct {
    pthread_mutex_t     lock;
} ce_lock_t;

void ce_lock_init(ce_lock_t *lock);
void ce_lock_destroy(ce_lock_t *lock);

void ce_lock_lock(ce_lock_t *lock);
void ce_lock_unlock(ce_lock_t *lock);


typedef struct {
    pthread_rwlock_t    lock;
} ce_rwlock_t;

void ce_rwlock_init(ce_rwlock_t *lock);
void ce_rwlock_destroy(ce_rwlock_t *lock);

void ce_rwlock_wlock(ce_rwlock_t *lock);
void ce_rwlock_wunlock(ce_rwlock_t *lock);

void ce_rwlock_rlock(ce_rwlock_t *lock);
void ce_rwlock_runlock(ce_rwlock_t *lock);


typedef ce_atomic_t ce_spinlock_t;

void ce_spinlock_init(ce_spinlock_t *lock);
void ce_spinlock_destroy(ce_spinlock_t *lock);

void ce_spinlock_lock(ce_spinlock_t *lock);
void ce_spinlock_unlock(ce_spinlock_t *lock);

#endif
